<template>
    <div id="backg">
        <h1 class="title">答题方式</h1>
        <van-button type="primary" class="choose-btn" @click="goTo">手机公众号答题</van-button><br/>
        <!-- <van-button type="primary" class="choose-btn" @click="getMedia">现场答题后扫码</van-button> -->
        <div id="video"></div>
        <div style="width:300px;margin:0 auto; padding:20px 0;">
          <a target="_blank" href="http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=13020302001048" style="display:inline-block;text-decoration:none;height:20px;line-height:20px;">
            <img src="../assets/countryicon.png" style="float:left;"/><p style="float:left;height:20px;line-height:20px;margin: 0px 0px 0px 5px; color:#939393;">冀公网安备 13020302001048号</p >
          </a >
        </div>
        <a href="https://beian.miit.gov.cn/" target="_blank" rel="noopener noreferrer" style="height:20px;line-height:20px;margin: 0px 0px 0px 5px; color:#939393;">冀ICP备2021009292号-2</a>
    </div>
</template>
<script>
import axios from "axios";
// import "http://res.wx.qq.com/open/js/jweixin-1.6.0.js"
export default {
    data() {

    },
    created(){
        let params = new URLSearchParams(location.search);
        var code = params.get('code')
        // var fromURL = params.get('fromURL')
        var _this = this;
        if(code){
            var data=axios(
            {
                url:"/api/home/user/openId",
                method:"post",
                data:{
                "uc":code
                },
                contentType:"text",
                processData: false,
                dataType:"text"
            }
            ).then(function (response){
                _this.openID = response.data.data.open_id
                window.localStorage.setItem("openID",_this.openID)
                _this.uid = response.data.data.uid;
                if(_this.uid!=0){//说明已经有信息了
                    window.localStorage.setItem("uid",_this.uid)
                }else{
                    _this.$router.push({name:'login',query:{fromURL:"choose"}})
                }
            })
        }

    },
    methods: {
        goTo() {
            this.$router.push('questions')
        },
        getMedia() {
            // wx.scanQRCode({
            //     needResult: 0, // 默认为0，扫描结果由微信处理，1则直接返回扫描结果，
            //     scanType: ["qrCode","barCode"], // 可以指定扫二维码还是一维码，默认二者都有
            //     success: function (res) {
            //         var result = res.resultStr; // 当needResult 为 1 时，扫码返回的结果
            //     }
            // });
        }
    }
}
</script>
<style>
#backg{
  background: url(./../assets/bg.png);
  background-size: 100% 100%;
 height: 100%;
 position: fixed;
 width: 100%
}
.choose-btn{
    width: 70%;
    font-size: 20px;
    margin: 2rem;
}
</style>